home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 23 / Amiga Format AFCD23 (Feb 1998, Issue 107).iso / -seriously_amiga- / shareware / graphics / povray3 / povray3_060 / include / shapesq.inc < prev    next >
Text File  |  1997-12-12  |  11KB  |  338 lines

  1. #ifdef(ShapesQ_Inc_Temp)
  2. // do nothing
  3. #else
  4. #declare ShapesQ_Inc_Temp = version
  5. #version 3.0
  6.  
  7. #ifdef(View_POV_Include_Stack)
  8. #   debug "including shapesq.inc\n"
  9. #end
  10.  
  11. /*
  12.               Persistence of Vision Raytracer Version 3.0
  13.                       Quartic shapes include file
  14.               Several cubic and quartic shape definitions
  15.                           by Alexander Enzmann
  16.  
  17.  In the following descriptions, multiplication of two terms is
  18.  shown as the two terms next to each other (i.e. x y, rather than
  19.  x*y.  The expression c(n, m) is the binomial coefficient, n!/m!(n-m)!.
  20.  
  21. */
  22.  
  23. /* Bicorn
  24.   This curve looks like the top part of a paraboloid, bounded
  25.   from below by another paraboloid.  The basic equation is:
  26.      y^2 - (x^2 + z^2) y^2 - (x^2 + z^2 + 2 y - 1)^2 = 0.  */
  27. #declare Bicorn =
  28.  quartic
  29.   {< 1,   0,   0,   0,  1,   0,   4,   2,   0, -2,
  30.      0,   0,   0,   0,  0,   0,   0,   0,   0,  0,
  31.      0,   0,   0,   1,  0,   3,   0,   4,   0, -4,
  32.      1,   0,  -2,   0,  1>
  33.   }
  34.  
  35. /* Crossed Trough
  36.   This is a surface with four pieces that sweep up from the x-z plane.
  37.   The equation is: y = x^2 z^2.  */
  38. #declare Crossed_Trough =
  39.  quartic
  40.   {< 0,   0,   0,   0,  0,   0,   0,   4,   0,  0,
  41.      0,   0,   0,   0,  0,   0,   0,   0,   0,  0,
  42.      0,   0,   0,   0,  0,   0,   0,   0,   0, -1,
  43.      0,   0,   0,   0,  0>
  44.   }
  45.  
  46. /* a drop coming out of water? This is a curve formed by using the equation
  47.   y = 1/2 x^2 (x + 1) as the radius of a cylinder having the x-axis as
  48.   its central axis. The final form of the equation is:
  49.      y^2 + z^2 = 0.5 (x^3 + x^2) */
  50. #declare Cubic_Cylinder =
  51.  quartic 
  52.   {< 0,   0,   0,   -0.5, 0,   0,   0,   0,   0, -0.5,
  53.      0,   0,   0,    0,   0,   0,   0,   0,   0,  0,
  54.      0,   0,   0,    0,   0,   1,   0,   0,   0,  0,
  55.      0,   0,   1,    0,   0>
  56.   }
  57.  
  58. /* a cubic saddle. The equation is: z = x^3 - y^3. */
  59. #declare Cubic_Saddle_1 =
  60.  quartic 
  61.   {< 0,   0,   0,    1,   0,   0,   0,   0,   0,  0,
  62.      0,   0,   0,    0,   0,   0,   0,   0,   0,  0,
  63.      0,   0,  -1,    0,   0,   0,   0,   0,   0,  0,
  64.      0,   0,   0,   -1,   0>
  65.   }
  66.  
  67. /* Variant of a devil's curve in 3-space.  This figure has a top and
  68.   bottom part that are very similar to a hyperboloid of one sheet,
  69.   however the central region is pinched in the middle leaving two
  70.   teardrop shaped holes. The equation is:
  71.      x^4 + 2 x^2 z^2 - 0.36 x^2 - y^4 + 0.25 y^2 + z^4 = 0.  */
  72. #declare Devils_Curve =
  73.  quartic 
  74.   {<-1,   0,   0,    0,  0,   0,    0,  -2,   0,  0.36,
  75.      0,   0,   0,    0,  0,   0,    0,   0,   0,  0,
  76.      1,   0,   0,    0,  0,  -0.25, 0,   0,   0,  0,
  77.     -1,   0,   0,    0,  0>
  78.    }
  79.  
  80. /* Folium
  81.   This is a folium rotated about the x-axis.  The formula is:
  82.      2 x^2 - 3 x y^2 - 3 x z^2 + y^2 + z^2 = 0. */
  83. #declare Folium =
  84.  quartic 
  85.   {< 0,   0,   0,    0,  0,   0,   0,   0,   0,  2,
  86.      0,   0,  -3,    0,  0,   0,   0,  -3,   0,  0,
  87.      0,   0,   0,    0,  0,   1,   0,   0,   0,  0,
  88.      0,   0,   1,    0,  0>
  89.   }
  90.  
  91. /* Glob - sort of like basic teardrop shape. The equation is:
  92.    y^2 + z^2 = 0.5 x^5 + 0.5 x^4. */
  93. #declare Glob_5 =
  94.  poly 
  95.   {5,
  96.    <-0.5, 0,   0,  -0.5, 0,   0,   0,   0,   0,  0,
  97.      0,   0,   0,   0,   0,   0,   0,   0,   0,  0,
  98.      0,   0,   0,   0,   0,   0,   0,   0,   0,  0,
  99.      0,   0,   0,   0,   0,   0,   0,   0,   0,  0,
  100.      0,   0,   0,   0,   1,   0,   0,   0,   0,  0,
  101.      0,   0,   0,   1,   0,   0>
  102.   }
  103.  
  104. /* Variant of a lemniscate - the two lobes are much more teardrop-like. */
  105. #declare Twin_Glob =
  106.  poly 
  107.   {6,
  108.    < 4,   0,   0,   0,   0,   0,   0,   0,   0, -4,
  109.      0,   0,   0,   0,   0,   0,   0,   0,   0,  0,
  110.      0,   0,   0,   0,   0,   0,   0,   0,   0,  0,
  111.      0,   0,   0,   0,   0,   0,   0,   0,   0,  0,
  112.      0,   0,   0,   0,   0,   0,   0,   0,   0,  0,
  113.      0,   0,   0,   0,   0,   0,   0,   0,   0,  0,
  114.      0,   0,   0,   0,   0,   0,   0,   0,   0,  0,
  115.      1,   0,   0,   0,   0,   0,   0,   0,   0,  0,
  116.      0,   1,   0,   0>
  117.   }
  118.  
  119. /*  Approximation to the helix z = arctan(y/x).
  120.  
  121.    The helix can be approximated with an algebraic equation (kept to the
  122.    range of a quartic) with the following steps:
  123.  
  124.       tan(z) = y/x   =>  sin(z)/cos(z) = y/x   =>
  125.  
  126.    (1) x sin(z) - y cos(z) = 0
  127.  
  128.    Using the taylor expansions for sin, cos about z = 0,
  129.  
  130.       sin(z) = z - z^3/3! + z^5/5! - ...
  131.       cos(z) = 1 - z^2/2! + z^6/6! - ...
  132.  
  133.    Throwing out the high order terms, the expression (1) can be written as:
  134.  
  135.       x (z - z^3/6) - y (1 + z^2/2) = 0, or
  136.  
  137.   (2) -1/6 x z^3 + x z + 1/2 y z^2 - y = 0
  138.  
  139.   This helix (2) turns 90 degrees in the range 0 <= z <= sqrt(2)/2.  By using
  140.   scale <2 2 2>, the helix defined below turns 90 degrees in the range
  141.   0 <= z <= sqrt(2) = 1.4042.
  142. */
  143. #declare Helix =
  144.  quartic 
  145.   {<  0,   0,   0,    0,  0,   0,   0,      0,   0,  0,
  146.       0,   0,   0,    0,  0,   0,  -0.1666, 0,   1,  0,
  147.       0,   0,   0,    0,  0,   0,   0,      0.5, 0, -1,
  148.       0,   0,   0,    0,  0>
  149.    clipped_by
  150.     {object {Cylinder_Z scale 2}
  151.      plane  { z, 1.4142}
  152.      plane  {-z, 0}
  153.     }
  154.    bounded_by{clipped_by}
  155.   }
  156.  
  157. /* This is an alternate Helix, using clipped_by instead of csg intersection. */
  158. #declare Helix_1 = object {Helix}
  159.  
  160. /* Hyperbolic Torus having major radius sqrt(40), minor radius sqrt(12).
  161.   This figure is generated by sweeping a circle along the arms of a
  162.   hyperbola.  The equation is:
  163.  
  164.      x^4 + 2 x^2 y^2 - 2 x^2 z^2 - 104 x^2 + y^4 - 2 y^2 z^2 +
  165.      56 y^2 + z^4 + 104 z^2 + 784 = 0.
  166.  
  167.   See the description for the torus below. */
  168. #declare Hyperbolic_Torus_40_12 =
  169.  quartic 
  170.   {< 1,   0,   0,    0,     2,   0,   0,  -2,   0, -104,
  171.      0,   0,   0,    0,     0,   0,   0,   0,   0,    0,
  172.      1,   0,   0,   -2,     0,  56,   0,   0,   0,    0,
  173.      1,   0, 104,    0,   784>
  174.   }
  175.  
  176. /* Lemniscate of Gerono
  177.   This figure looks like two teardrops with their pointed ends connected.
  178.   It is formed by rotating the Lemniscate of Gerono about the x-axis.
  179.   The formula is:
  180.      x^4 - x^2 + y^2 + z^2 = 0. */
  181. #declare Lemniscate =
  182.  quartic 
  183.   {< 1,   0,   0,   0,   0,   0,   0,   0,   0, -1,
  184.      0,   0,   0,   0,   0,   0,   0,   0,   0,  0,
  185.      0,   0,   0,   0,   0,   1,   0,   0,   0,  0,
  186.      0,   0,   1,   0,   0>
  187.   }
  188.  
  189. /* This is a figure with a bumpy sheet on one side and something that
  190.   looks like a paraboloid (but with an internal bubble).  The formula
  191.   is:
  192.      (x^2 + y^2 + a c x)^2 - (x^2 + y^2)(c - a x)^2.
  193.  
  194.    -99*x^4+40*x^3-98*x^2*y^2-98*x^2*z^2+99*x^2+40*x*y^2+40*x*z^2+y^4+2*y^2*z^2
  195.    -y^2+z^4-z^2
  196.  
  197. */
  198. #declare Quartic_Loop_1 =
  199.  quartic 
  200.   {<99,   0,   0, -40,  98,   0,   0,  98,   0, -99,
  201.      0,   0, -40,   0,   0,   0,   0, -40,   0,   0,
  202.     -1,   0,   0,  -2,   0,   1,   0,   0,   0,   0,
  203.     -1,   0,   1,   0,   0>
  204.   }
  205.  
  206. /* Monkey Saddle
  207.   This surface has three parts that sweep up and three down.  This gives
  208.   a saddle that has a place for two legs and a tail... The equation is:
  209.  
  210.      z = c (x^3 - 3 x y^2).
  211.  
  212.   The value c gives a vertical scale to the surface - the smaller the
  213.   value of c, the flatter the surface will be (near the origin). */
  214. #declare Monkey_Saddle =
  215.  quartic 
  216.   {< 0,   0,   0,   1,  0,   0,   0,   0,   0,  0,
  217.      0,   0,  -3,   0,  0,   0,   0,   0,   0,  0,
  218.      0,   0,   0,   0,  0,   0,   0,   0,   0,  0,
  219.      0,   0,   0,  -1,  0>
  220.   }
  221.  
  222. /* Parabolic Torus having major radius sqrt(40), minor radius sqrt(12).
  223.   This figure is generated by sweeping a circle along the arms of a
  224.   parabola.  The equation is:
  225.  
  226.      x^4 + 2 x^2 y^2 - 2 x^2 z - 104 x^2 + y^4 - 2 y^2 z +
  227.      56 y^2 + z^2 + 104 z + 784 = 0.
  228.  
  229.   See the description for the torus below. */
  230. #declare Parabolic_Torus_40_12 =
  231.  quartic 
  232.   {< 1,   0,   0,    0,     2,   0,   0,   0,  -2, -104,
  233.      0,   0,   0,    0,     0,   0,   0,   0,   0,    0,
  234.      1,   0,   0,    0,    -2,  56,   0,   0,   0,    0,
  235.      0,   0,   1,  104,   784>
  236.   }
  237.  
  238. /* Piriform
  239.   This figure looks like a hersheys kiss. It is formed by sweeping
  240.   a Piriform about the x-axis.  a basic form of the equation is:
  241.      (x^4 - x^3) + y^2 + z^2 = 0.
  242. */
  243. #declare Piriform =
  244.  quartic 
  245.   {< 4,   0,   0,   -4,  0,   0,   0,   0,   0,  0,
  246.      0,   0,   0,    0,  0,   0,   0,   0,   0,  0,
  247.      0,   0,   0,    0,  0,   1,   0,   0,   0,  0,
  248.      0,   0,   1,    0,  0>
  249.   }
  250.  
  251. /* n-Roll Mill
  252.   This curve in the plane looks like several hyperbolas with their
  253.   bumps arranged about the origin.  The general formula is:
  254.  
  255.      x^n - c(n,2) x^(n-2) y^2 + c(n,4) x^(n-4) y^4 - ... = a
  256.  
  257.   When rendering in 3-Space, the resulting figure looks like a
  258.   cylinder with indented sides.
  259. */
  260.  
  261. /* Quartic parabola - a 4th degree polynomial (has two bumps at the bottom)
  262.   that has been swept around the z axis. The equation is:
  263.      0.1 x^4 - x^2 - y^2 - z^2 + 0.9 = 0. */
  264. #declare Quartic_Paraboloid =
  265.  quartic 
  266.   {< 0.1, 0,   0,  0,   0,   0,   0,   0,   0,  -1,
  267.      0,   0,   0,  0,   0,   0,   0,   0,   0,   0,
  268.      0,   0,   0,  0,   0,   0,   0,   0,   0,  -1,
  269.      0,   0,  -1,  0,   0.9>
  270.   }
  271.  
  272. /* Quartic Cylinder - a Space Needle?  */
  273. #declare Quartic_Cylinder =
  274.  quartic 
  275.   {< 0,   0,   0,    0,   1,   0,   0,   0,   0,   0.01,
  276.      0,   0,   0,    0,   0,   0,   0,   0,   0,   0,
  277.      0,   0,   0,    1,   0,   0,   0,   0,   0,   0,
  278.      0,   0,   0.01, 0,  -0.01>
  279.   }
  280.  
  281. /* Steiners quartic surface */
  282. #declare Steiner_Surface =
  283.  quartic 
  284.   {< 0,   0,   0,  0,  1,   0,   0,   1,   0,   0,
  285.      0,   0,   0,  0,  1,   0,   0,   0,   0,   0,
  286.      0,   0,   0,  1,  0,   0,   0,   0,   0,   0,
  287.      0,   0,   0,  0,  0>
  288.   }
  289.  
  290. /* Torus having major radius sqrt(40), minor radius sqrt(12) */
  291. #declare Torus_40_12 =
  292.  quartic 
  293.   {< 1,   0,   0,    0,     2,   0,   0,   2,   0, -104,
  294.      0,   0,   0,    0,     0,   0,   0,   0,   0,    0,
  295.      1,   0,   0,    2,     0,  56,   0,   0,   0,    0,
  296.      1,   0, -104,   0,   784>
  297.   }
  298.  
  299. /* Witch of Agnesi */
  300. #declare Witch_Hat =
  301.  quartic 
  302.   {<  0,   0,   0,   0,   0,   0,   1,   0,   0,   0,
  303.       0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  304.       0,   0,   0,   0,   0,   0,   0,   1,   0,   0.04,
  305.       0,   0,   0,   0,   0.04>
  306.   }
  307.  
  308. /* very rough approximation to the sin-wave surface z = sin(2 pi x y).
  309.   In order to get an approximation good to 7 decimals at a distance of
  310.   1 from the origin would require a polynomial of degree around 60.  This
  311.   would require around 200k coefficients. For best results, scale by
  312.   something like <1 1 0.2>. */
  313. #declare Sinsurf =
  314.  poly 
  315.   {6,
  316.    <    0,   0,   0,    0,  0,   0,   0,   0,   0,  0,
  317.     -1116.226, 0, 0,    0,  0,   0,   0,   0,   0,  0,
  318.         0,   0,   0,    0,  0,   0,   0,   0,   0,  0,
  319.         0,   0,   0,    0,  0,   0,   0,   0,   0,  0,
  320.         0,   0,   0,    0,  0,   0,   0,   0,   0, 18.8496,
  321.         0,   0,   0,    0,  0,   0,   0,   0,   0,  0,
  322.         0,   0,   0,    0,  0,   0,   0,   0,   0,  0,
  323.         0,   0,   0,    0,  0,   0,   0,   0,   0,  0,
  324.         0,   0,  -1,    0>
  325.    }
  326.  
  327. /* Empty quartic equation.  Ready to be filled with numbers...
  328.   quartic
  329.    {< 0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  330.       0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  331.       0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  332.       0,   0,   0,   0,   0>
  333.    }
  334. */
  335.  
  336. #version ShapesQ_Inc_Temp
  337. #end
  338.